﻿using Common;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ado.MSSql
{
    public class SqlHelper
    {
        private static string ConnStr =StaticConstant.ConnStr;
        public static void ExecuteDataReader(string strSql, Action act, out SqlDataReader dr, params SqlParameter[] paras)
        {
            using (SqlConnection myConn = new SqlConnection(ConnStr))
            {
                myConn.Open();
                using (SqlCommand cmd = new SqlCommand(strSql, myConn))
                {
                    cmd.Parameters.AddRange(paras);
                    using (dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            act.Invoke();
                        }
                    }
                }
            }
        }
    }
}
